<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>圈子管理</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">

    <%@include file="../include/commonFile.jsp" %>
</head><body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <form class="layui-form" action="${ctx}/circle/list.do" id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo"/>
                <input type="hidden" name="memberId" id="memberId" value="${contact.memberId }"/>
                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable">名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="name" autocomplete="off" class="layui-input"
                                           value="${circle.name}" placeholder="请输入">
                                </div>
                            </li>
                            <li class="form-item-inline"><label class="search-form-lable">发布者</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="memberName" autocomplete="off" class="layui-input"
                                           value="${input.memberName}" placeholder="请输入查询发布者">
                                </div>
                            </li>
                            <li class="form-item-inline">
                                <div class="sub-btns">
                                    <a class="layui-btn layui-btn-danger"
                                       href="javascript:submitFunction('#myForm')">查询</a>
                                    <a class="layui-btn layui-btn-normal"
                                       href="javascript:resetFunction('#myForm')">重置</a>
                                </div>
                            </li>
                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">创建时间</label>
                                <div class="check-btn-inner" id="timeType">
                                    <a id="all" href="javascript:void(0);"
                                       onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                    <input type="hidden" name="timeType" value="${input.timeType}"/>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createStart"
                                               value="${input.createStart}" placeholder="开始日">
                                    </div>
                                    -
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createEnd"
                                               value="${input.createEnd}" placeholder="截止日">
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>
            <div class="list-content">
                <div class="cl">
                    <table class="layui-table">
                        <colgroup>
                            <col>
                            <col width="200px">
                            <col width="90px">
                            <col width="90px">
                            <col width="150px">
                            <col>
                        </colgroup>
                        <thead>
                        <tr>
                            <th>名称</th>
                            <th>圈主</th>
                            <th>会员数</th>
                            <th>话题数</th>
                            <th>创建时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="circle" items="${list}">
                            <tr>
                                <td class="table-member" title="${circle.name}">
                                    <div class="member-cell">
                                        <div class="member-logo common-img"
                                             >
                                            <img src="<c:if test="${circle.logo != null}">${circle.logo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                        </div>
                                        <div class="member-name ellipsis-1">${circle.name}</div>
                                    </div>
                                </td>
                                <td class="table-member"
                                    onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${circle.mgrId}','400px','470px')">
                                    <div class="member-cell">
                                        <div class="member-logo common-img"
                                             >
                                            <img src="<c:if test="${circle.mgrLogo != null}">${circle.mgrLogo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                        </div>
                                        <div class="member-name ellipsis-1"><a class="blue"
                                                                               title="${circle.mgrRealname}"
                                                                               href="javascript:void(0);">${circle.mgrRealname}</a>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <div>${circle.member_num == null ? 0 : circle.member_num}</div>
                                </td>
                                <td>
                                    <div>${circle.topic_num == null ? 0 : circle.topic_num}</div>
                                </td>
                                <td>
                                    <div><fmt:formatDate value="${circle.create_date}"
                                                         pattern="yyyy-MM-dd HH:mm"/></div>
                                </td>
                                    <%--<td>--%>
                                    <%--<div class="ellipsis-1">${circle.memo}</div>--%>
                                    <%--</td>--%>
                                <td class="tb-opts">
                                    <div class="comm-opts">
                                        <a class="qr-btn" target="_self" class=""
                                           href="javascript:txz.openQrDialog({
                                           title:'扫描二维码可预览分享',
                                           detailList:[{
                                             title:'详情二维码',
                                             url:'${circle.qrCodeUrl}'
                                           },{
                                                title:'通讯录二维码',
                                                url:'${circle.qrABCodeUrl}'
											}
                                           ]});">
                                            二维码
                                        </a>
                                        <a target="_self" class="" href="${ctx}/circle/member/list.do?id=${circle.id}">
                                            会员管理
                                        </a>
                                        <a target="_self" class=""
                                           href="${ctx}/circle/apply/list.do?circle=${circle.id}">
                                            会员审核
                                        </a>
                                        <a target="_self" class=""
                                           href="${ctx}/circle/topic/list.do?circle=${circle.id}">
                                            话题管理
                                        </a>
                                        <a target="_self" class="" href="${ctx}/circle/tag/list.do?circle=${circle.id}">
                                            用户类型管理
                                        </a>
                                        <a target="_self" class=""
                                           href="${ctx}/circle/topicTag/list.do?circle=${circle.id}">
                                            话题类型管理
                                        </a>
                                        <a href="javascript:createPhotos('${circle.id}')">生成相册</a>
                                        <a target="_self" class="green" href="${ctx}/circle/form.do?id=${circle.id}">
                                            编辑
                                        </a>
                                        <a target="_self" class="red" href="javascript:txz.deleteObject('确定删除该圈子么？', '${ctx}/circle/dissolveCircle.do?id=${circle.id}')">
                                            删除
                                        </a>
                                    </div>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                    <c:if test="${page.totalCount == 0}">
                        <div class="f16 tc mt15">还没有圈子</div>
                    </c:if>
                </div>
            </div>
            <div id="page_content" class="page-container"></div>
        </div>
        <!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>
    <div class="f-def-dialog" id="circleQr" data-url="">
        <div class="f-dialog-shadow"></div>
        <div class="f-dialog-content">
            <span class="close-icon"><i class="iconfont icon-close"></i></span>
            <div class="dialog-detail">
                <p class="f16 gray">扫码二维码可预览分享</p>
                <div class="content">
                    <div> <img class="download-img" src=""/>
                        <div>
                            <a class="download-qrcode" href="javascript:void(0);" data-url="">下载二维码</a>
                        </div></div>
                </div>

            </div>
        </div>
    </div>
</div>
<div class="out-fix-opts">
    <ul class="options-content">
        <li><a target="_self" class="" href="/admin/circle/apply/list.do?circle=8be8f5e96e554cb29d369e9178b85dc7">
            会员审核
        </a></li>
        <li><a target="_self" class="" href="/admin/circle/topic/list.do?circle=8be8f5e96e554cb29d369e9178b85dc7">
            话题管理
        </a></li>
        <li><a target="_self" class="" href="/admin/circle/tag/list.do?circle=8be8f5e96e554cb29d369e9178b85dc7">
            用户类型管理
        </a></li>
        <li><a target="_self" class="" href="/admin/circle/topicTag/list.do?circle=8be8f5e96e554cb29d369e9178b85dc7">
            话题类型管理
        </a></li>
        <li><a target="_self" class="green" href="/admin/circle/form.do?id=8be8f5e96e554cb29d369e9178b85dc7">
            编辑
        </a></li>
        <li><a target="_self" class="red" href="javascript:delCircle('8be8f5e96e554cb29d369e9178b85dc7')">
            删除
        </a></li>
    </ul>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">
    function createPhotos(id) {
        var content = "确定要生成相册吗？";
        layer.confirm(content, {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            var type = $("[name=type]:checked").val() || '2';
            layer.close(index);
            //loading层
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post("${ctx}/circle/createPhotos.do", {
                id: id,
                type: type
            }, function (data) {
                layer.close(loadIndex);
                setTimeout(function () {
                    if (data.success == true) {
                        location.href = "${ctx}/photo/photoproject/list.do";
                    } else {
                        util.layerMsgError("生成失败")
                    }
                }, 500);// 延时0.5秒
            })
        });
    }
    function openQr(url) {
        $('#circleQr').data('url', url);
        $('#circleQr .download-img').prop('src', '${qr_code}' + '/' + url);
        $('#circleQr .download-qrcode').attr('data-url', url);
        $('#circleQr').fadeIn();
        $('#circleQr .f-dialog-shadow').click(function () {
            $('#circleQr').fadeOut();
        })
    }

    <%--showActive('${input.createStart}', '${input.createEnd}', '#timeType');--%>


    $(function () {
        loadPageNew({elem: 'page_content', totalCount: '${page.totalCount}', limit: '${page.limit}', page: '${page.page}'});
        layui.use(['laydate'], function () {
            var laydate = layui.laydate;
            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });
        $('.f-def-dialog .download-qrcode').click(function (e) {
            var url = $(this).attr("data-url")
            download('${ctx}', url);
        });
    });

</script>
<script type="text/javascript">
    txz.initHeader({
        nav:[{
            name: '圈子管理',
            curr: true
        }],
        info:'<span class="f12">共<b id="totalCount">${page.totalCount}</b>条记录</span>',
        btns:[{
            name: '创建圈子',
            href: '${ctx}/circle/form.do',
            icon: 'add'
        }]
    });
</script>
</body>
</html>